/*eslint-disable */
import paTableTpl from './paTable.html';
import loadingTpl from '!html-loader!./tableLoading.html';

function paTableComponent($compile, $interval) {
  'ngInject';

  return {
    restrict: 'E',
    templateUrl: paTableTpl,
    transclude: true,
    link(scope, iElement) {
      const loadingEle = angular.element(loadingTpl);
      $compile(loadingEle)(scope);
      iElement.find('tbody').prepend(loadingEle);


      $interval(() => {
        const length = iElement.find('table th').length;
        scope.length = length;
      }, 50, 50);
    },
  };
}

export default paTableComponent;
